{extend name="public:_base" /}
{block name="css"}
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadify/uploadify.css">
{/block}
{block name="js"}
{load href="__STATIC__/admin/hui/lib/My97DatePicker/4.8/WdatePicker.js" /}
{load href="__STATIC__/admin/login/js/jquery-1.4.2.min.js" /}
{include file="public/_validform"}
<!--上传配置 -->
<script src="__STATIC__/admin/js/upfile.js" type="text/javascript"></script>

<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/admin/hui/lib/ueditor/1.4.3/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/admin/hui/lib/ueditor/1.4.3/ueditor.all.js"></script>

<script type="text/javascript">
    var ue = UE.getEditor('editor');
    $("[name='cid']").find("[value='{$data.cid ?$data.cid :$Request.param.addcid }']").attr("selected", true);

    $("[name='cknums']").find("[value='{$data.cknums ?? ''}']").attr("selected", true);
    upload_image('image','','300','300','500');
    var URL = {
        uploader: '{:url('Upload/image')}',
        swf:'__STATIC__/admin/uploadify/uploadify.swf',
        ROOT:'__PUBLIC__/uploads/image',
    }

    function addDeltbody(i) {

        //document.getElementById("div_add_del_" + i).value = "";
        //document.getElementById("svalue" + i).value = "";
        if (i != 1) {
            document.getElementById("div_add_del_" + i).style.display = "none";
            document.getElementById("add" + i).style.display = "";
        }
    }
    function addTabody(i) {

        document.getElementById('div_add_del_' + i).style.display = "";
        document.getElementById('add' + i).style.display = "none";
    }

    function delrow(obj, tbody,objid) {

        $("#"+tbody).remove();
        var obj = {id:objid}

        $.post("{:url('Vote/del_tab')}", obj,
            function(data) {

            },
            "json");
    }

</script>
{/block}
{block name="main"}
<div class="page-container">

    <form class="form form-horizontal" action="{:url(\''.\\think\\Request::instance()->controller().'/save')}" id="form" method="post">
            <input type="hidden" name="id" value="{$data['id'] ?? ''}">
        <input type="hidden" value="{$data.cid ?? $addcid}" name="cidold" />
        <table class="layui-table">
            <tbody>
            {include file="public:_navadd"}

            <tr>
            <th width="120">关键词：</th>
            <td><input type="text" name="keyword" value="{$data['keyword']??'投票'}" class="px" style="width:550px;"></td>
        </tr>
        <tr>
            <th width="120">投票标题：</th>
            <td><input type="text" name="title" value="{$data.title??''}" class="px" style="width:550px;"></td>
        </tr>
        <tr style="display: none">
            <th>投票图片：</th>
            <td>
                <if condition="$reslist['picurl'] neq ''">
                    <img class="thumb_img" id="picurl_src" src="{$reslist['picurl']??''}" style="max-height:100px;">
                </if>
                <input type="text" name="picurl" value="{$data.picurl??''}" class="px" onclick="document.getElementById('picurl_src').src=this.value;" id="picurl" style="width:300px;">
                <script src="/tpl/static/upyun.js"></script><a href="###" onclick="upyunPicUpload('picurl',700,400,'{$token??''}')" class="a_upload">上传</a> <a href="###" onclick="viewImg('picurl')">预览</a>&nbsp;填写图片外链地址，大小为720x400</td>
        </tr>
        <tr style="display: none">
            <th>图片显示：</th>
            <td><label>
                <input type="radio" name="showpic" value="1" checked="checked" id="showpic2">
                显示在投票页面</label>
                <label>
                    <input name="showpic" type="radio" id="showpic1" value="0">
                    不显示在投票页面</label>
            </td>
        </tr>
        <tr>
            <th valign="top">投票说明：</th>
            <td valign="top">
                <script id="editor" type="text/plain" name="info" style="width:100%;height:400px;">{$data.info|default=''|html_entity_decode ?? ''}</script>
            </td>
        </tr>
        <tr>
            <th valign="top">投票选项：</th>
            <td valign="top"><div class="bdrcontent">
                <div id="div_ptype">
                    <table class="ListProduct" border="0" cellspacing="0" cellpadding="0" width="100%">

                        <tbody>
                        <tr>

                            <td width="260">选项标题</td>
                            <td width="50">排序</td>
                            <td width="50">票数</td>
                            <td class="norightborder"></td>
                        </tr>
                        </tbody>
                        {notempty name="$items"}
                            {volist name="items" id="ivo"}
                                <tbody id="div_add_del_{$i+50}" name="div_add_del">
                                <tr>
                                    <input type="hidden" name="add[id][]"   value="{$ivo.id}" style="width:20px;">
                                    <td width="120"><input type="text" name="add[item][]" value="{$ivo.item}" class="px" style="width:120px;"></td>
                                    <td width="20"><input type="text" name="add[rank][]" value="{$ivo.rank}" style="width:20px;" class="px"></td>
                                    <td width="20"><input type="text" name="add[vcount][]" value="{$ivo.vcount}" style="width:20px;" class="px"></td>
                                    <td width="50" class="norightborder"><a href="javascript:;" onclick="delrow(this, 'div_add_del_{$i+50}',{$ivo.id});">删除</a></td>
                                </tr>
                                </tbody>
                            {/volist}

                        {/notempty}

                        <tbody id="div_add_del_1" name="div_add_del">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:20px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value="" placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>

                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(1)">删除</a>
                                <a href="javascript:;" id="add2" onclick="addTabody(2)">添加</a></td>
                        </tr>
                        </tbody>

                        <tbody id="div_add_del_2" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:20px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value="" placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(2)">删除</a>
                                <a href="javascript:;" id="add3" onclick="addTabody(3)">添加</a></td>
                        </tr>
                        </tbody>

                        <tbody id="div_add_del_3" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value="" placeholder="请填写选项标题"  class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(3)">删除</a>
                                <a href="javascript:;" id="add4" onclick="addTabody(4)">添加</a></td>
                        </tr>
                        </tbody>


                        <tbody id="div_add_del_4" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" placeholder="请填写选项标题" value="" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(4)">删除</a>
                                <a href="javascript:;" id="add5" onclick="addTabody(5)">添加</a></td>
                        </tr>
                        </tbody>


                        <tbody id="div_add_del_5" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value=""  placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>

                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(5)">删除</a>
                                <a href="javascript:;" id="add6" onclick="addTabody(6)">添加</a></td>
                        </tr>
                        </tbody>

                        <tbody id="div_add_del_6" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value=""  placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(6)">删除</a>
                                <a href="javascript:;" id="add7" onclick="addTabody(7)">添加</a></td>
                        </tr>
                        </tbody>

                        <tbody id="div_add_del_7" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value=""  placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(7)">删除</a>
                                <a href="javascript:;" id="add8" onclick="addTabody(8)">添加</a></td>
                        </tr>
                        </tbody>
                        <tbody id="div_add_del_8" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value=""  placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(8)">删除</a>
                                <a href="javascript:;" id="add9" onclick="addTabody(9)">添加</a></td>
                        </tr>
                        </tbody>
                        <tbody id="div_add_del_9" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value=""  placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(9)">删除</a>
                                <a href="javascript:;" id="add10" onclick="addTabody(10)">添加</a></td>
                        </tr>
                        </tbody>

                        <tbody id="div_add_del_10" name="div_add_del" style="display:none">
                        <tr >
                            <input type="hidden" name="add[id][]" readonly="readonly" disabled="disabled"  value="" style="width:50px;" >
                            <td width="120">
                                <input type="text" name="add[item][]" value=""  placeholder="请填写选项标题" class="px" style="width:120px;">
                            </td>
                            <td>
                                <input type="text" name="add[rank][]" value="" style="width:20px;" class="px">
                            </td>
                            <td>
                                <input type="text" name="add[vcount][]" value="" style="width:20px;" class="px">
                            </td>
                            <td width="50" class="norightborder"><a href="javascript:;" onclick="addDeltbody(10)">删除</a>
                            </td>
                        </tr>
                        </tbody>
                        <tr style="display:none">
                            <td colspan="4" class="norightborder">
                                排序默认为1，票数默认为0。
                        </tr>

                        </tbody>
                    </table>

                </div>
            </div>

            </td>
        </tr>
        <tr>
            <th>单选/多选：</th>
            <td>
                    <select name="cknums" class="select">
                        <option value="1">单选</option>
                        <option value="2" >多选</option>
                    </select>
            </td>
        </tr>

        <tr>
            <th>截至时间：</th>
            <td><input type="input" class="px" id="statdate" value="{$data.statdate??''}" onClick="WdatePicker({dateFmt:'yyyy-MM-dd  HH:mm:ss'})" name="statdate">
                到
                <input type="input" class="px" id="enddate" value="{$data.enddate??''}" name="enddate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd  HH:mm:ss'})"></td>
        </tr>
        <!--
        <tr>
        <th>投票结果：</th>
        <td>
        <label>
        <input name="display" type="radio" <if condition="$data['display'] eq 1">checked</if>  value="1" id="RadioGroup2_1">
        投票前可见</label>
        <label>
        <input name="display" type="radio" <if condition="$data['display'] eq 0">checked <else/> checked</if> id="RadioGroup2_0" value="0">
        投票后可见</label>
        <label>
        <input name="display" type="radio" <if condition="$data['display'] eq 2">checked</if>id="RadioGroup2_2" value="2">
        投票结束可见</label>

        </td>
        </tr>

        -->
        <tr>
            <th>&nbsp;</th>
            <td>
                <input type="hidden" name="display" value="1">
                <input name="id" value="{$data.id ?? ''}"  type="hidden" />
                <input type="hidden" value="{$data.cid ?? $addcid}" name="cidold" />
                {:token()}
                        <input class="btn radius btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                        <input class="btn radius btn-default radius" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;">
                        <!-- <button onClick="layer_close();" class="btn radius btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button> -->

            </td>
        </tr>
        </tbody>
        </table>



    </form>

</div>

{/block}